<template>
    <div class="contentWeb clear">
        <div class="member_menu">
            <Personleft active="yixiang"/>
        </div>
        <div class="member_right ">
            <div class="personTengt">
                <Memtitle name="求职意向"/>
                <div class="jingyan" v-for="(item, index) in datalist" :key="index">
                    <div class="mktitle clear">
                        <div class="mleft">
                            <span>{{item.position}}</span>
                            <span>期望{{item.wageType}}：{{item.startWage}} - {{item.endWage}}</span>
                        </div>
                        <div class="mright">
                            <i class="el-icon-edit" @click="edit(item.id)"></i>
                            <i class="el-icon-delete" @click="deleteCVJobIntention(item.id)"></i>
                        </div>
                    </div>
                    <div class="desc">
                        <span>{{item.industry}}</span>
                        <span>{{item.workType}}</span>
                        <span>期望工作地点：{{item.workplace}}</span>
                    </div>
                </div>

                <div v-if="datalist.length < 5" style="text-align: center; margin-top: 50px;">
                    <el-button type="primary" @click="add" style="background: #20a2b2; width: 298px; border: 0;">
                        新增求职意向
                    </el-button>

                </div>
            </div>
        </div>
    </div>
</template>
<script type="text/babel">
// @ is an alias to /src

import Memtitle from '../../components/memtitle'
import Personleft from '../../components/personleft'
import { getJobIntentList, deleteExperience, workType, deleteCVJobIntention } from '../../assets/js/domains'

export default {
  name: 'PersonYixiang',
  components: {
    Personleft,
    Memtitle
  },
  directives: {},
  data: function () {
    return {
      workType: workType,
      datalist: [],
      user_uid: ''
    }
  },
  created: function () {
    document.documentElement.scrollTop = document.body.scrollTop = 0
  },
  computed: {},
  mounted: function () {
    this.user_uid = localStorage.getItem('md_user_uid')
    this.getpost()
  },
  methods: {
    onSubmit: function () {
    },
    add: function () {
      this.$router.push({ path: 'yixiangAdd' })
    },
    getpost: function () {
      const _this = this
      getJobIntentList({ user_uid: this.user_uid }).then(function (res) {
        if (res.code === 200) {
          _this.datalist = res.data
        }
      })
    },
    edit: function (id) {
      this.$router.push({
        path: 'yixiangAdd',
        query: { id: id }
      })
    },
    // 删除
    deleteCVJobIntention: function (id) {
      const _this = this
      this.$confirm('此操作将永久删除该求职意向, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function () {
        deleteCVJobIntention({ id: id }).then(function (res) {
          if (res.code === 200) {
            _this.$message({
              type: 'success',
              message: '删除成功!'
            })
            _this.getpost()
          }
        })
      }).catch(function () {
        _this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    }
  }
}
</script>
<style lang="less" scoped>
    @import "../../assets/css/member";
</style>
